import {
    createStore
} from 'vuex'

import a from "vuex-persistedstate";  //安装cnpm install --save vuex-persistedstate

export default createStore({
    state: {
        userInfo: '',
        user: [],
        editableTabs: [],
        color: ''
    },
    mutations: {
        cunToken(state, user) {
            state.userInfo = user
        },
        addName(state, user) {
            state.user = user
        },
        addTop(state, user) {
            state.editableTabs.push(user)
        },
        remTop(state, user) {
            state.editableTabs = state.editableTabs.filter(item => {
                return item.title != user
            })
        },
        addColor(state, obj) {
            state.color = obj
            console.log(state.color);
        }
    },
    getters: {

    },
    actions: {
        addToken({ commit }, data) {
            commit("cunToken", data);
        }
    },
    modules: {},
    plugins: [a()]
})
